﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace T.Contract.Repository
{
    public interface IRepository<T> where T : class, new()
    {
        /// <summary>
        /// 异步添加
        /// </summary>
        /// <param name="entity">泛型实体</param>
        /// <returns>返回受影响的行数</returns>
        Task<int> AddAsync(T entity);

        /// <summary>
        /// 异步请求所有数据
        /// </summary>
        /// <returns>返回泛型实体集合</returns>
        Task<List<T>> GetAllAsync();

        /// <summary>
        /// 异步请求指定ID的数据
        /// </summary>
        /// <param name="id">主键ID</param>
        /// <returns>返回泛型实体</returns>
        Task<T> GetModelAsync(int id);

        /// <summary>
        /// 异步删除指定ID的数据
        /// </summary>
        /// <param name="entity">泛型实体</param>
        /// <returns>返回受影响的行数</returns>
        Task<int> UpdateAsync(T entity);

        /// <summary>
        /// 异步请求指定条件的数据
        /// </summary>
        /// <param name="expre">条件表达式</param>
        /// <returns>返回泛型实体集合</returns>
        Task<List<T>> GetAsync(Expression<Func<T, bool>> expre);
       
    }
}
